//
// Created by DELL on 2021/3/20.
//

#ifndef SYLAR_HTTP_SERVER_H
#define SYLAR_HTTP_SERVER_H

#include "tcp_server.h"
#include "http_session.h"
#include "servlet.h"

namespace sylar {
    namespace http {
        class HttpServer : public TcpServer {
        public:
            using ptr = std::shared_ptr<HttpServer>;

            explicit HttpServer(bool keepalive = false,
                                sylar::IOManager *worker = sylar::IOManager::GetThis(),
                                sylar::IOManager *io_worker = sylar::IOManager::GetThis(),
                                sylar::IOManager *accept_worker = sylar::IOManager::GetThis());

            ServletDispatch::ptr getServletDispatch() const { return m_dispatch; }

            void setServletDispatch(ServletDispatch::ptr v) { m_dispatch = v; }

            void setName(const std::string &v) override;

        protected:
            void handleClient(Socket::ptr client) override;

        private:
            bool m_isKeepalive;
            ServletDispatch::ptr m_dispatch;
        };
    }
}
#endif //SYLAR_HTTP_SERVER_H
